package sg.edu.nus.iss.jass.prototype;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.util.Vector;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

import sg.edu.nus.iss.billing.gui.component.ColumnAction;
import sg.edu.nus.iss.billing.gui.component.CustomizableJTable;
import sg.edu.nus.iss.billing.gui.component.ScrollableCustomizableJTable;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class DemoForAdvSearchList extends javax.swing.JFrame {
    private JPanel SearchSectionPanel;
    private JPanel SearchResultPanel;
    private JTable searchResultTable;
    private JScrollPane scrollableSearchResultTable;

    /**
    * Auto-generated main method to display this JFrame
    */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                DemoForAdvSearchList inst = new DemoForAdvSearchList();
                inst.setLocationRelativeTo(null);
                inst.setVisible(true);
            }
        });
    }
    
    public DemoForAdvSearchList() {
        super();
        initGUI();
    }
    
    private void initGUI() {
        try {
            {
                SearchSectionPanel = new JPanel();
                getContentPane().add(SearchSectionPanel, BorderLayout.NORTH);
                SearchSectionPanel.setPreferredSize(new java.awt.Dimension(392, 57));
            }
            {
                SearchResultPanel = new JPanel();
                getContentPane().add(SearchResultPanel, BorderLayout.CENTER);
                SearchResultPanel.setPreferredSize(new java.awt.Dimension(392, 200));
                SearchResultPanel.setLayout(null);
                {
                    Vector<String> columnNames = new Vector<String>();
                    columnNames.add("Selected");
                    columnNames.add("FieldValue1");
                    columnNames.add("FieldValue2");
                    columnNames.add("FieldValue3");
                    columnNames.add("Click to Modify");
                    columnNames.add("Click to View");
                    
                    String [] styles = 
                    {CustomizableJTable.CHECKBOX_STYLE, 
                     CustomizableJTable.NORMAL_STYLE, 
                     CustomizableJTable.NORMAL_STYLE, 
                     CustomizableJTable.NORMAL_STYLE,
                     CustomizableJTable.BUTTON_STYLE,
                     CustomizableJTable.BUTTON_STYLE
                    };
                    
                    int [] columnsWidth = {5,50,50,50,100,100};
                    
                    int size = 50;
                    
                    searchResultTable = new CustomizableJTable(columnNames, size, styles, columnsWidth);
                    scrollableSearchResultTable = new ScrollableCustomizableJTable((CustomizableJTable)searchResultTable);
                    scrollableSearchResultTable.setBounds(0, 0, 500, 200);
                    scrollableSearchResultTable.addColumnActions(new ColumnAction() {
                        @Override
                        public void actionPerformed(int columnIndex, Object[] inputParams) {
                            // TODO Auto-generated method stub
                            if (columnIndex == 4) {
                                System.out.println("Try to modified at : " + columnIndex);
                            }
                            
                        }
                    });
                    SearchResultPanel.add(scrollableSearchResultTable);
                }
            }
            setSize(600, 300);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
